<?php

class myUser extends sfGuardSecurityUser
{
	public function getCheckoutDetails()
	{
    if ($this->isAuthenticated())
      return $this->getProfile()->getCheckoutDetails();

    return $this->getAttribute('checkout_details');

//    return array
//		(
//			'name' => '',
//			'surname' => '',
//			'address' => '',
//			'zip' => '',
//			'city_id' => '',
//			'telephone' => '',
//			'email' => ''
//		);
	}

//      public function forgetCheckoutDetails()
//      {
//        return $this->setAttribute('checkout_details', array(
//            'name' => '',
//            'surname' => '',
//            'address' => '',
//            'zip' => '',
//            'city_id' => '',
//            'telephone' => '',
//            'email' => ''
//          ));
//      }

	public function getFullAddress()
	{
		$details = $this->getCheckoutDetails();
		return array
		(
			'street'=>$details['address'],
			'city'=>CityTable::getInstance()->find($details['city_id'])->getNazivPu(),
			'country'=>'Hrvatska'
		);

	}

	public function getShopperId()
	{
		return $this->getAttribute('shopper_id');
	}

	public function removeShopperId()
	{
		sfContext::getInstance()->getResponse()->setCookie
		(
			sfConfig::get('app_kliks_shopper_cookie_name', 'kliks_shopper_id'), null, time() - 1
		);
	}

	public function generateRandomKey($len = 20)
	{
		return parent::generateRandomKey($len);
	}
}
